package leetcodecompetition.D371;

import java.util.Arrays;

/**
 * @Author: Siantar
 * @Date: 2023-11-12-10:37
 * @Description: 1.0
 */
public class T100124 {
    public int maximumStrongPairXor(int[] nums) {
        Arrays.sort(nums);
        int n = nums.length;
        int p = 0;
        int res = 0;
        for (int i = 0; i < n; i++) {
            while (nums[i] > 2 * nums[p]) {
                p++;
            }
            for (int j = p; j <= i; j++) {
                res = Math.max(res, nums[i] ^ nums[j]);
            }
        }
        return res;
    }
}
